package com.xiaoxi.open.design.creation.builderpattern.director;

import com.xiaoxi.open.design.creation.builderpattern.builder.IBuilder;
import com.xiaoxi.open.design.creation.builderpattern.domain.MyDomain;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author xiaoxi
 * @ProjectName creation_pattern
 * @PackageName com.xiaoxi.open.design.creation.builderpattern.diretor
 * @ClassName Director
 * @Description TODO
 * @Date 2024/5/14 10:48
 * @Version 1.0
 */
@Service
@Slf4j
public class Director {

    public void printContent(IBuilder iBuilder) {

        iBuilder.open();

        iBuilder.buildTitle(iBuilder.getClass().getName());
        iBuilder.buildString("购物");
        List<MyDomain> shopping = new ArrayList<>();
        MyDomain myDomain1 = new MyDomain();
        myDomain1.setUrl("https://uland.taobao.com/sem/tbsearch");
        myDomain1.setContent("淘宝");
        MyDomain myDomain2 = new MyDomain();
        myDomain2.setUrl("https://www.pinduoduo.com/");
        myDomain2.setContent("拼多多");
        MyDomain myDomain3 = new MyDomain();
        myDomain3.setUrl("https://www.jd.com/?");
        myDomain3.setContent("京东");
        shopping.add(myDomain1);
        shopping.add(myDomain2);
        shopping.add(myDomain3);
        iBuilder.buildTray(shopping);


        iBuilder.buildString("搜索");
        List<MyDomain> search = new ArrayList<>();
        MyDomain myDomain4 = new MyDomain();
        myDomain4.setUrl("https://www.baidu.com/");
        myDomain4.setContent("百度");
        MyDomain myDomain5 = new MyDomain();
        myDomain5.setUrl("https://cn.bing.com/?FORM=BEHPTB");
        myDomain5.setContent("必应");
        search.add(myDomain4);
        search.add(myDomain5);
        iBuilder.buildTray(search);

        iBuilder.close();

    }

}
